#include "message_box.h"
#include <QKeyEvent>
#include <QLabel>
#include <QPainter>
#include <QPushButton>

namespace hjcb {

Messagebox::Messagebox(QWidget* parent) : DialogWithButtons(parent) { }

Messagebox::Messagebox(const QString& title, const QString& text,
                       QMessageBox::StandardButtons buttons,
                       QMessageBox::StandardButton default_button, QWidget* parent,
                       const QHash<int, QString>& button_texts)
    : DialogWithButtons(title, buttons, default_button, parent, button_texts)
{
    text_label_ = new QLabel(client());
    text_label_->setObjectName("text_label");
    text_label_->setWordWrap(true);
    text_label_->setText(text);
    text_label_->setAlignment(Qt::AlignCenter);
    text_label_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    setWidget(text_label_);
    adjustSize();
}

QMessageBox::StandardButton Messagebox::warning(QWidget* parent, const QString& title,
                                                const QString& text,
                                                QMessageBox::StandardButtons buttons,
                                                QMessageBox::StandardButton default_button,
                                                const QHash<int, QString>& button_texts)
{
    Messagebox m(title, text, buttons, default_button, parent, button_texts);
    m.exec();
    return m.result();
}

QMessageBox::StandardButton Messagebox::information(QWidget* parent, const QString& title,
                                                    const QString& text,
                                                    QMessageBox::StandardButtons buttons,
                                                    QMessageBox::StandardButton default_button,
                                                    const QHash<int, QString>& button_texts)
{
    Messagebox m(title, text, buttons, default_button, parent, button_texts);
    m.exec();
    return m.result();
}

QMessageBox::StandardButton Messagebox::question(QWidget* parent, const QString& title,
                                                 const QString& text,
                                                 QMessageBox::StandardButtons buttons,
                                                 QMessageBox::StandardButton default_button,
                                                 const QHash<int, QString>& button_texts)
{
    Messagebox m(title, text, buttons, default_button, parent, button_texts);
    m.exec();
    return m.result();
}

} // namespace hjcb
